// 校验数据有效性
function checkdatas(params) {
    return params === undefined || params === null || params === 'null' || params === 'undefined' || params === '' ? true : false;
}
// 拼接搜索条件算法
function searchSql(obj) {
    let sql = 'where ';
    for (let [key, value] of Object.entries(obj)) {
        if (value !== undefined) {
            sql += `${key} like '%${value}%' and `;
        } 
    };
    return sql.substring(0, sql.length - 5);
   
};
// 修改数据算法
function updateSql(obj) {
    let sql = "";
    for (let [key, value] of Object.entries(obj)) {
        if (typeof value === 'string') {
            sql += `${key}="${value}",`;
        } else {
            sql += `${key}=${value},`;
        }
    }
    return sql.substring(0, sql.length - 1);
}
module.exports = {
    checkdatas,
    searchSql,
    updateSql
}